home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: Greatest Hits 1996 / Amiga Games: Greatest Hits 1996.iso / userbox / publicdomain / xfd / developper / amigae / eprograms / xfdtextview.e < prev   
Text File  |  1996-08-03  |  2KB  |  64 lines

  1. -> show a textfile in a nice juicy scrolling window
  2. -> NEW from DII: XFD support added 12/4/96
  3.  
  4. MODULE 'tools/file', 'tools/exceptions', 'class/sctext',
  5.     'xfdmaster','libraries/xfdmaster','exec/memory'
  6.  
  7. DEF xfdmasterbase
  8.  
  9. PROC main() HANDLE
  10.   DEF m,l,n,list,sc=NIL:PTR TO scrolltext,
  11.     bufinf=NIL:PTR TO xfdbufferinfo,cruncher,ttl[60]:STRING,succ=FALSE
  12.   openxfd()
  13.   bufinf:=XfdAllocObject(XFDOBJ_BUFFERINFO)
  14.   IF bufinf
  15.     m,l:=readfile(arg)
  16.     cruncher:='ASCII'
  17.     bufinf.sourcebuffer:=m
  18.     bufinf.sourcebuflen:=l
  19.     IF XfdRecogBuffer(bufinf)
  20.     IF bufinf.packerflags AND (XFDPFF_PASSWORD OR XFDPFF_KEY16 OR XFDPFF_KEY32)
  21.         WriteF('Unsupported. Requires password or key.\n')
  22.         Raise("p/k")
  23.     ENDIF
  24.     bufinf.targetbufmemtype:=MEMF_PUBLIC
  25.     IF XfdDecrunchBuffer(bufinf)
  26.         l:=bufinf.targetbufsavelen
  27.         m:=bufinf.targetbuffer
  28.         cruncher:=bufinf.packername
  29.         succ:=TRUE
  30.     ELSE
  31.         WriteF('Failed to decrunch file.\n')
  32.         Raise("decr")
  33.     ENDIF
  34.     ENDIF
  35.     list:=stringsinfile(m,l,n:=countstrings(m,l))
  36.     NEW sc.settext(list,100)
  37.     StringF(ttl,'TextView 1.0 (\s)',cruncher)
  38.     sc.open(ttl,20,20,300,150)
  39.     WHILE sc.handle()=FALSE DO Wait(-1)
  40.   ELSE
  41.     WriteF('Couldn''t allocate XFD buffer info.\n')
  42.     Raise("MEM")
  43.   ENDIF
  44.   Raise(0)
  45. EXCEPT DO
  46.   IF sc THEN END sc
  47.   IF succ THEN FreeMem(bufinf.targetbuffer,bufinf.targetbuflen)
  48.   IF bufinf THEN XfdFreeObject(bufinf)
  49.   IF xfdmasterbase THEN CloseLibrary(xfdmasterbase)
  50.   report_exception()
  51. ENDPROC
  52.  
  53. PROC openxfd(v=36)
  54.     xfdmasterbase:=OpenLibrary('xfdmaster.library',v)
  55.     IF xfdmasterbase=NIL
  56.     WriteF('Missing "xfdmaster.library" V\d!\n',v)
  57.     Raise("xfd")
  58.     ENDIF
  59. ENDPROC
  60.  
  61.  
  62.  
  63.  
  64.